/**
 * 
 */
package cn.biplam.front.template.control.pop;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.html.HtmlDiv;
import cn.biplam.front.html.base.Html;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.template.Template;
import cn.biplam.front.template.control.pop.PopLevel.PopMenu_Layer;

/**
 * 无标题栏、有关闭按钮的信息框
 */
public class FramePopMenu implements Template{
	
	@SuppressWarnings("unused")
	private UserInfo mUser;
	
	private HtmlDiv frame;
	private HtmlDiv content;
	private String ID;
	@SuppressWarnings("unused")
	private String sHomeUrl;
	
	/**
	 * 功能：构造方法
	 * @param ID		Frame的页面ID(不能为空)
	 * @param sHomeUrl	主页Url
	 * @throws ErrorMessage 
	 */
	public FramePopMenu(String ID,String sHomeUrl,UserInfo mUser) throws ErrorMessage{
		if(ID==null || ""==ID) throw new ErrorMessage("Frame控件ID不能为空!");
		this.ID = ID;
		this.sHomeUrl=sHomeUrl;
		this.mUser=mUser;
		this.frame=new HtmlDiv(ID,"fpd");
		this._init();
	}
	
	private void _init() throws ErrorMessage{
		this.setSize(300, 200);
		
		/**创建边框*/
		HtmlDiv border=new HtmlDiv(null,null);
		frame.put(border);

		/**创建内容*/
		this.content=new HtmlDiv(this.ID+"c",null);
		border.put(this.content);
	}
	
	/**
	 * 功能：向Frame正文区域放入Html对象
	 * @param html
	 * @throws ErrorMessage
	 */
	public void put(Html html) throws ErrorMessage{
		this.content.put(html);
	}
	
	/**
	 * 功能：向Frame父容器放入Html对象
	 * @param html
	 * @throws ErrorMessage
	 */
	public void putFrame(Html html) throws ErrorMessage{
		this.frame.put(html);
	}
	
	/**
	 * 功能：设置frame正文区域的宽度和高度(标题高度是20px)
	 * @param width
	 * @param height
	 * @throws ErrorMessage
	 */
	public void setSize(int width,int height) throws ErrorMessage{
		this.frame.setStyleWidth(Integer.toString(width));
		this.frame.setStyleHeight(Integer.toString(height+20));
	}
	
	/**
	 * 功能：设置Frame的布局层次
	 * @param layer {@link Layer_Index}
	 * @throws ErrorMessage
	 */
	public void setLayerIndex(PopMenu_Layer layer) throws ErrorMessage{
		this.frame.setZIndex(layer.toString());
	}
	
	
	/**
	 * 功能：绑定Frame的确认按钮事件
	 * @param sScript	事件执行的js脚本
	 * @throws ErrorMessage
	 */
	public void bindSubmit(String sScript) throws ErrorMessage{
	}
	
	/**
	 * 功能：返回设置好的HtmlWindow对象
	 * @return
	 * @throws ErrorMessage 
	 */
	public HtmlWindow get() throws ErrorMessage{
		return this.frame;
	}

}
